package vip.xiaonuo.smzq.modular.kcl.controller;

import javax.annotation.Resource;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import vip.xiaonuo.smzq.modular.kcl.entity.Yf;
import vip.xiaonuo.smzq.modular.kcl.service.IYfService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.validation.annotation.Validated;
import vip.xiaonuo.common.pojo.CommonResult;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;


/**
 * 压覆
 *
 * @author eomer
 * @since 2024-02-22
 */
@Api(tags = "压覆")
@RestController
@RequestMapping("/kcl/yf")
@Validated
public class YfController {

    @Resource
    private IYfService iYfService;

    /**
     * 添加压覆
     */
    @ApiOperation("添加压覆")
    @PostMapping("/add")
    public CommonResult<String> add(@RequestBody @Valid Yf yf) {
        iYfService.save(yf);
        return CommonResult.ok();
    }

    /**
     * 删除压覆
     */
    @ApiOperation("删除压覆")
    @PostMapping("/delete")
    public CommonResult<String> delete(@ApiParam(name = "pkid", value = "主键") @RequestParam String pkid) {
        iYfService.removeById(pkid);
        return CommonResult.ok();
    }

    /**
     * 编辑压覆
     */
    @ApiOperation("编辑压覆")
    @PostMapping("/edit")
    public CommonResult<String> edit(@RequestBody @Valid Yf yf) {
        iYfService.updateById(yf);
        return CommonResult.ok();
    }

    /**
     * 压覆分页查询
     */
    @ApiOperation("压覆分页查询")
    @GetMapping("/list")
    public CommonResult<Page<Yf>> page() {
        return CommonResult.data(iYfService.page(new Yf()));
    }

    /**
     * 压覆分页查询
     */
    @ApiOperation("压覆分页查询")
    @GetMapping("/getYfList")
    public CommonResult<List<Yf>> getYfList(
            @ApiParam(name = "kqbm", value = "矿区编码", required = true) @RequestParam String kqbm,
            @ApiParam(name = "djflbm", value = "登记分类编码", required = true) @RequestParam Integer djflbm,
            @ApiParam(name = "nd", value = "年度", required = true) @RequestParam Integer nd
    ) {
        return CommonResult.data(iYfService.getYfList(kqbm, djflbm, nd));
    }
}
